package com.example.model.controller;

import com.example.model.dao.UserDao;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;


public class UserFindServlet extends HttpServlet {


    protected void doGet(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        UserDao dao = new UserDao();
        PrintWriter out;
        //[1.调用dao]将查询命令推送到数据库服务器上，得到所有的用户信息【list】
//		List<Users> userList=dao.finAll();
        //2.【调用相应对象】将用户信息结合<table>以二进制写入到响应体中
        response.setContentType("text/html;charset=UTF-8");
        out = response.getWriter();
        out.print("<table border='2' align='center'>");
        out.print("<tr>");
        out.print("<td>用户编号</td>");
        out.print("<td>用户姓名</td>");
        out.print("<td>用户密码</td>");
        out.print("<td>用户性别</td>");
        out.print("<td>用户邮箱</td>");
        out.print("<td>操作</td>");
        out.print("</tr>");
//		 for(Users users:userList) {
//			 out.print("<tr>");
//			 out.print("<td>"+users.getUserId()+"</td>");
//			 out.print("<td>"+users.getUserName()+"</td>");
//			 out.print("<td>******</td>");
//			 out.print("<td>"+users.getSex()+"</td>");
//			 out.print("<td>"+users.getEmail()+"</td>");
//			 out.print("<td><a href='/14-examSystem/userdelete?userId="+users.getUserId()+"'>删除用户</a></td>");
//			 out.println("</tr>");
//		 }
        out.println("</table>");
    }

}
